﻿namespace ExamV5.ManagSys
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class ManagSetRubricName : Page
    {
        protected Button butDefault;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private PublicFun publicFun_0 = new PublicFun();
        protected ScriptManager SM;
        protected TextBox txtRubicA;
        protected TextBox txtRubicB;
        protected TextBox txtRubicC;
        protected TextBox txtRubicD;
        protected TextBox txtRubicE;
        protected TextBox txtRubicF;
        protected TextBox txtRubicG;
        protected TextBox txtRubicH;
        protected TextBox txtRubicI;
        protected TextBox txtRubicJ;
        protected UpdatePanel UPPart;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            string str = "";
            str = "delete from SysParmInfo where ParmMemo='RubricType';";
            str = (((((((((str + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicA.Text.Trim()) + "','A','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicB.Text.Trim()) + "','B','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicC.Text.Trim()) + "','C','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicD.Text.Trim()) + "','D','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicE.Text.Trim()) + "','E','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicF.Text.Trim()) + "','F','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicG.Text.Trim()) + "','G','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicH.Text.Trim()) + "','H','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicI.Text.Trim()) + "','I','RubricType');") + "insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('" + this.publicFun_0.CheckString(this.txtRubicJ.Text.Trim()) + "','J','RubricType');";
            this.publicFun_0.ExecuteSql(str + ";insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('编辑题型命名！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('题型命名操作成功！')", true);
        }

        private void method_0()
        {
            int num = 0;
            string cmdText = "select ParmName from SysParmInfo where ParmMemo='RubricType' order by ParmValue";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand(cmdText, connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                switch (num)
                {
                    case 0:
                        this.txtRubicA.Text = reader["ParmName"].ToString();
                        break;

                    case 1:
                        this.txtRubicB.Text = reader["ParmName"].ToString();
                        break;

                    case 2:
                        this.txtRubicC.Text = reader["ParmName"].ToString();
                        break;

                    case 3:
                        this.txtRubicD.Text = reader["ParmName"].ToString();
                        break;

                    case 4:
                        this.txtRubicE.Text = reader["ParmName"].ToString();
                        break;

                    case 5:
                        this.txtRubicF.Text = reader["ParmName"].ToString();
                        break;

                    case 6:
                        this.txtRubicG.Text = reader["ParmName"].ToString();
                        break;

                    case 7:
                        this.txtRubicH.Text = reader["ParmName"].ToString();
                        break;

                    case 8:
                        this.txtRubicI.Text = reader["ParmName"].ToString();
                        break;

                    case 9:
                        this.txtRubicJ.Text = reader["ParmName"].ToString();
                        break;
                }
                num++;
            }
            if (this.txtRubicA.Text.Trim() == "")
            {
                this.txtRubicA.Text = "单选题";
            }
            if (this.txtRubicB.Text.Trim() == "")
            {
                this.txtRubicB.Text = "多选题";
            }
            if (this.txtRubicC.Text.Trim() == "")
            {
                this.txtRubicC.Text = "判断题";
            }
            if (this.txtRubicD.Text.Trim() == "")
            {
                this.txtRubicD.Text = "填空题";
            }
            if (this.txtRubicE.Text.Trim() == "")
            {
                this.txtRubicE.Text = "简答题";
            }
            if (this.txtRubicF.Text.Trim() == "")
            {
                this.txtRubicF.Text = "作文题";
            }
            if (this.txtRubicG.Text.Trim() == "")
            {
                this.txtRubicG.Text = "论述题";
            }
            if (this.txtRubicH.Text.Trim() == "")
            {
                this.txtRubicH.Text = "分析题";
            }
            if (this.txtRubicI.Text.Trim() == "")
            {
                this.txtRubicI.Text = "操作题";
            }
            if (this.txtRubicJ.Text.Trim() == "")
            {
                this.txtRubicJ.Text = "综合题";
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) && (this.httpCookie_0.Value != ""))
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    if (this.publicFun_0.ReturnPaperData() == "Yes")
                    {
                        this.ViewState["UserPower"] = this.publicFun_0.GetValues("select ManagSysSet from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagSysSet");
                        this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                        if (this.ViewState["UserPower"].ToString() != "Y")
                        {
                            this.butDefault.Enabled = false;
                            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BPower", "alert('系统设置权限未开放！')", true);
                        }
                        this.method_0();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                    }
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

